let tableIns;
let tree;
layui.use(['element', 'form', 'layer'], function () {
    let form = layui.form;//select、单选、复选等依赖form
    let element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
    
    $(function(){
       //输入框的值改变时触发
      $("input[name='baseAmountPoint']").on("input",function(e){
        var val = $("input[name='serverAmountPoint']").val();
        $("input[name='overAmountPoint']").val(val - e.delegateTarget.value);
      });
    });
    
});

/**
 * 提交保存
 */
function refFormSave() {
    let refForm = $("#refForm").serializeObject();
    var reg = /^[0-9]{1,2}(\.[0-9]{0,2})?$/

    if(!reg.test(refForm.serverAmountPoint) && null != refForm.serverAmountPoint){
        layer.msg('签约点数输入不正确，格式为：x.x',{icon: 5});
        return false;
    }
    
    save();
}

function save(){
	let refForm = $("#refForm").serializeObject();
    $.post(ctx + "/seller/ref/saveRef",refForm, function (data) {
        console.log(data);
        if(data == null){
            layer.msg("访问接口出现异常!", {icon: 5});
        }else if(data!=null && data.flag){
	        layer.msg("修改成功", {icon: 1, time: 2000}, function(){
	        	var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
	        	parent.layer.close(index); //再执行关闭
	        	window.parent.$("#queryBySellerNameBtn").click();
	        });
    	} else {
    		layer.msg("保存失败!"+data.msg, {icon: 5});
    	}
    });
}